import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2022-12-29
 * Time: 下午 20:00
 */
@WebServlet("/studentInfo")
public class StudentInfo extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String queryString = req.getQueryString();

        resp.setContentType("text/html;charset=utf8");
        String classId = req.getParameter("classId");
        String studentId = req.getParameter("studentId");
        //把queryString里面key值对应的value值输出到控制台
        System.out.println("classId: " + classId + " studentId: " + studentId );
        //把queryString里面key值对应的value值输出到页面上
        resp.getWriter().write("classId: " + classId + " studentId: " + studentId );
        resp.getWriter().write("<br>");
        //把queryString输出到页面上
        resp.getWriter().write(queryString);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html;charset=utf8");

        String classId = req.getParameter("classId");
        String studentId = req.getParameter("studentId");
        resp.getWriter().write("classId: " + classId + " studentId: " + studentId );
        System.out.println("classId: " + classId + " studentId: " + studentId );

    }
}
